/*****************************************************************************************
This file is part of Proactive Investigator Analytics.

Proactive Investigator Analytics is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Proactive Investigator Analytics is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Proactive Investigator Analytics.  If not, see <http://www.gnu.org/licenses/>.

This script creates SMTP partition function/scheme, tables, indexes and view.

*****************************************************************************************/
USE RiskSecurityDW
GO

-- Create partition function
CREATE PARTITION FUNCTION [SMTP_DayDateRange2PF](datetime) AS RANGE LEFT FOR VALUES (N'2011-01-01T00:00:00.000', N'2011-01-02T00:00:00.000', 
N'2011-01-03T00:00:00.000', N'2011-01-04T00:00:00.000', N'2011-01-05T00:00:00.000', N'2011-01-06T00:00:00.000', N'2011-01-07T00:00:00.000', 
N'2011-01-08T00:00:00.000', N'2011-01-09T00:00:00.000', N'2011-01-10T00:00:00.000', N'2011-01-11T00:00:00.000', N'2011-01-12T00:00:00.000', 
N'2011-01-13T00:00:00.000', N'2011-01-14T00:00:00.000', N'2011-01-15T00:00:00.000', N'2011-01-16T00:00:00.000', N'2011-01-17T00:00:00.000', 
N'2011-01-18T00:00:00.000', N'2011-01-19T00:00:00.000', N'2011-01-20T00:00:00.000', N'2011-01-21T00:00:00.000', N'2011-01-22T00:00:00.000', 
N'2011-01-23T00:00:00.000', N'2011-01-24T00:00:00.000', N'2011-01-25T00:00:00.000', N'2011-01-26T00:00:00.000', N'2011-01-27T00:00:00.000', 
N'2011-01-28T00:00:00.000', N'2011-01-29T00:00:00.000', N'2011-01-30T00:00:00.000', N'2011-01-31T00:00:00.000', N'2011-02-01T00:00:00.000', 
N'2011-02-02T00:00:00.000', N'2011-02-03T00:00:00.000', N'2011-02-04T00:00:00.000', N'2011-02-05T00:00:00.000', N'2011-02-06T00:00:00.000', 
N'2011-02-07T00:00:00.000', N'2011-02-08T00:00:00.000', N'2011-02-09T00:00:00.000', N'2011-02-10T00:00:00.000', N'2011-02-11T00:00:00.000', 
N'2011-02-12T00:00:00.000', N'2011-02-13T00:00:00.000', N'2011-02-14T00:00:00.000', N'2011-02-15T00:00:00.000', N'2011-02-16T00:00:00.000', 
N'2011-02-17T00:00:00.000', N'2011-02-18T00:00:00.000', N'2011-02-19T00:00:00.000', N'2011-02-20T00:00:00.000', N'2011-02-21T00:00:00.000', 
N'2011-02-22T00:00:00.000', N'2011-02-23T00:00:00.000', N'2011-02-24T00:00:00.000', N'2011-02-25T00:00:00.000', N'2011-02-26T00:00:00.000', 
N'2011-02-27T00:00:00.000', N'2011-02-28T00:00:00.000', N'2011-03-01T00:00:00.000', N'2011-03-02T00:00:00.000', N'2011-03-03T00:00:00.000', 
N'2011-03-04T00:00:00.000', N'2011-03-05T00:00:00.000', N'2011-03-06T00:00:00.000', N'2011-03-07T00:00:00.000', N'2011-03-08T00:00:00.000', 
N'2011-03-09T00:00:00.000', N'2011-03-10T00:00:00.000', N'2011-03-11T00:00:00.000', N'2011-03-12T00:00:00.000', N'2011-03-13T00:00:00.000', 
N'2011-03-14T00:00:00.000', N'2011-03-15T00:00:00.000', N'2011-03-16T00:00:00.000', N'2011-03-17T00:00:00.000', N'2011-03-18T00:00:00.000', 
N'2011-03-19T00:00:00.000', N'2011-03-20T00:00:00.000', N'2011-03-21T00:00:00.000', N'2011-03-22T00:00:00.000', N'2011-03-23T00:00:00.000', 
N'2011-03-24T00:00:00.000', N'2011-03-25T00:00:00.000', N'2011-03-26T00:00:00.000', N'2011-03-27T00:00:00.000', N'2011-03-28T00:00:00.000', 
N'2011-03-29T00:00:00.000', N'2011-03-30T00:00:00.000', N'2011-03-31T00:00:00.000', N'2011-04-01T00:00:00.000', N'2011-04-02T00:00:00.000', 
N'2011-04-03T00:00:00.000', N'2011-04-04T00:00:00.000', N'2011-04-05T00:00:00.000', N'2011-04-06T00:00:00.000', N'2011-04-07T00:00:00.000', 
N'2011-04-08T00:00:00.000', N'2011-04-09T00:00:00.000', N'2011-04-10T00:00:00.000', N'2011-04-11T00:00:00.000', N'2011-04-12T00:00:00.000', 
N'2011-04-13T00:00:00.000', N'2011-04-14T00:00:00.000', N'2011-04-15T00:00:00.000', N'2011-04-16T00:00:00.000', N'2011-04-17T00:00:00.000', 
N'2011-04-18T00:00:00.000', N'2011-04-19T00:00:00.000', N'2011-04-20T00:00:00.000', N'2011-04-21T00:00:00.000', N'2011-04-22T00:00:00.000', 
N'2011-04-23T00:00:00.000', N'2011-04-24T00:00:00.000', N'2011-04-25T00:00:00.000', N'2011-04-26T00:00:00.000', N'2011-04-27T00:00:00.000', 
N'2011-04-28T00:00:00.000', N'2011-04-29T00:00:00.000', N'2011-04-30T00:00:00.000', N'2011-05-01T00:00:00.000', N'2011-05-02T00:00:00.000', 
N'2011-05-03T00:00:00.000', N'2011-05-04T00:00:00.000', N'2011-05-05T00:00:00.000', N'2011-05-06T00:00:00.000', N'2011-05-07T00:00:00.000', 
N'2011-05-08T00:00:00.000', N'2011-05-09T00:00:00.000', N'2011-05-10T00:00:00.000', N'2011-05-11T00:00:00.000', N'2011-05-12T00:00:00.000', 
N'2011-05-13T00:00:00.000', N'2011-05-14T00:00:00.000', N'2011-05-15T00:00:00.000', N'2011-05-16T00:00:00.000', N'2011-05-17T00:00:00.000', 
N'2011-05-18T00:00:00.000', N'2011-05-19T00:00:00.000', N'2011-05-20T00:00:00.000', N'2011-05-21T00:00:00.000', N'2011-05-22T00:00:00.000', 
N'2011-05-23T00:00:00.000', N'2011-05-24T00:00:00.000', N'2011-05-25T00:00:00.000', N'2011-05-26T00:00:00.000', N'2011-05-27T00:00:00.000', 
N'2011-05-28T00:00:00.000', N'2011-05-29T00:00:00.000', N'2011-05-30T00:00:00.000', N'2011-05-31T00:00:00.000', N'2011-06-01T00:00:00.000', 
N'2011-06-02T00:00:00.000', N'2011-06-03T00:00:00.000', N'2011-06-04T00:00:00.000', N'2011-06-05T00:00:00.000', N'2011-06-06T00:00:00.000', 
N'2011-06-07T00:00:00.000', N'2011-06-08T00:00:00.000', N'2011-06-09T00:00:00.000', N'2011-06-10T00:00:00.000', N'2011-06-11T00:00:00.000', 
N'2011-06-12T00:00:00.000', N'2011-06-13T00:00:00.000', N'2011-06-14T00:00:00.000', N'2011-06-15T00:00:00.000', N'2011-06-16T00:00:00.000', 
N'2011-06-17T00:00:00.000', N'2011-06-18T00:00:00.000', N'2011-06-19T00:00:00.000', N'2011-06-20T00:00:00.000', N'2011-06-21T00:00:00.000', 
N'2011-06-22T00:00:00.000', N'2011-06-23T00:00:00.000', N'2011-06-24T00:00:00.000', N'2011-06-25T00:00:00.000', N'2011-06-26T00:00:00.000', 
N'2011-06-27T00:00:00.000', N'2011-06-28T00:00:00.000', N'2011-06-29T00:00:00.000', N'2011-06-30T00:00:00.000', N'2011-07-01T00:00:00.000', 
N'2011-07-02T00:00:00.000', N'2011-07-03T00:00:00.000', N'2011-07-04T00:00:00.000', N'2011-07-05T00:00:00.000', N'2011-07-06T00:00:00.000', 
N'2011-07-07T00:00:00.000', N'2011-07-08T00:00:00.000', N'2011-07-09T00:00:00.000', N'2011-07-10T00:00:00.000', N'2011-07-11T00:00:00.000', 
N'2011-07-12T00:00:00.000', N'2011-07-13T00:00:00.000', N'2011-07-14T00:00:00.000', N'2011-07-15T00:00:00.000', N'2011-07-16T00:00:00.000', 
N'2011-07-17T00:00:00.000', N'2011-07-18T00:00:00.000', N'2011-07-19T00:00:00.000', N'2011-07-20T00:00:00.000', N'2011-07-21T00:00:00.000', 
N'2011-07-22T00:00:00.000', N'2011-07-23T00:00:00.000', N'2011-07-24T00:00:00.000', N'2011-07-25T00:00:00.000', N'2011-07-26T00:00:00.000', 
N'2011-07-27T00:00:00.000', N'2011-07-28T00:00:00.000', N'2011-07-29T00:00:00.000', N'2011-07-30T00:00:00.000', N'2011-07-31T00:00:00.000', 
N'2011-08-01T00:00:00.000', N'2011-08-02T00:00:00.000', N'2011-08-03T00:00:00.000', N'2011-08-04T00:00:00.000', N'2011-08-05T00:00:00.000', 
N'2011-08-06T00:00:00.000', N'2011-08-07T00:00:00.000', N'2011-08-08T00:00:00.000', N'2011-08-09T00:00:00.000', N'2011-08-10T00:00:00.000', 
N'2011-08-11T00:00:00.000', N'2011-08-12T00:00:00.000', N'2011-08-13T00:00:00.000', N'2011-08-14T00:00:00.000', N'2011-08-15T00:00:00.000', 
N'2011-08-16T00:00:00.000', N'2011-08-17T00:00:00.000', N'2011-08-18T00:00:00.000', N'2011-08-19T00:00:00.000', N'2011-08-20T00:00:00.000', 
N'2011-08-21T00:00:00.000', N'2011-08-22T00:00:00.000', N'2011-08-23T00:00:00.000', N'2011-08-24T00:00:00.000', N'2011-08-25T00:00:00.000', 
N'2011-08-26T00:00:00.000', N'2011-08-27T00:00:00.000', N'2011-08-28T00:00:00.000', N'2011-08-29T00:00:00.000', N'2011-08-30T00:00:00.000', 
N'2011-08-31T00:00:00.000', N'2011-09-01T00:00:00.000', N'2011-09-02T00:00:00.000', N'2011-09-03T00:00:00.000', N'2011-09-04T00:00:00.000', 
N'2011-09-05T00:00:00.000', N'2011-09-06T00:00:00.000', N'2011-09-07T00:00:00.000', N'2011-09-08T00:00:00.000', N'2011-09-09T00:00:00.000', 
N'2011-09-10T00:00:00.000', N'2011-09-11T00:00:00.000', N'2011-09-12T00:00:00.000', N'2011-09-13T00:00:00.000', N'2011-09-14T00:00:00.000', 
N'2011-09-15T00:00:00.000', N'2011-09-16T00:00:00.000', N'2011-09-17T00:00:00.000', N'2011-09-18T00:00:00.000', N'2011-09-19T00:00:00.000', 
N'2011-09-20T00:00:00.000', N'2011-09-21T00:00:00.000', N'2011-09-22T00:00:00.000', N'2011-09-23T00:00:00.000', N'2011-09-24T00:00:00.000', 
N'2011-09-25T00:00:00.000', N'2011-09-26T00:00:00.000', N'2011-09-27T00:00:00.000', N'2011-09-28T00:00:00.000', N'2011-09-29T00:00:00.000', 
N'2011-09-30T00:00:00.000', N'2011-10-01T00:00:00.000', N'2011-10-02T00:00:00.000', N'2011-10-03T00:00:00.000', N'2011-10-04T00:00:00.000', 
N'2011-10-05T00:00:00.000', N'2011-10-06T00:00:00.000', N'2011-10-07T00:00:00.000', N'2011-10-08T00:00:00.000', N'2011-10-09T00:00:00.000', 
N'2011-10-10T00:00:00.000', N'2011-10-11T00:00:00.000', N'2011-10-12T00:00:00.000', N'2011-10-13T00:00:00.000', N'2011-10-14T00:00:00.000', 
N'2011-10-15T00:00:00.000', N'2011-10-16T00:00:00.000', N'2011-10-17T00:00:00.000', N'2011-10-18T00:00:00.000', N'2011-10-19T00:00:00.000', 
N'2011-10-20T00:00:00.000', N'2011-10-21T00:00:00.000', N'2011-10-22T00:00:00.000', N'2011-10-23T00:00:00.000', N'2011-10-24T00:00:00.000', 
N'2011-10-25T00:00:00.000', N'2011-10-26T00:00:00.000', N'2011-10-27T00:00:00.000', N'2011-10-28T00:00:00.000', N'2011-10-29T00:00:00.000', 
N'2011-10-30T00:00:00.000', N'2011-10-31T00:00:00.000', N'2011-11-01T00:00:00.000', N'2011-11-02T00:00:00.000', N'2011-11-03T00:00:00.000', 
N'2011-11-04T00:00:00.000', N'2011-11-05T00:00:00.000', N'2011-11-06T00:00:00.000', N'2011-11-07T00:00:00.000', N'2011-11-08T00:00:00.000', 
N'2011-11-09T00:00:00.000', N'2011-11-10T00:00:00.000', N'2011-11-11T00:00:00.000', N'2011-11-12T00:00:00.000', N'2011-11-13T00:00:00.000', 
N'2011-11-14T00:00:00.000', N'2011-11-15T00:00:00.000', N'2011-11-16T00:00:00.000', N'2011-11-17T00:00:00.000', N'2011-11-18T00:00:00.000', 
N'2011-11-19T00:00:00.000', N'2011-11-20T00:00:00.000', N'2011-11-21T00:00:00.000', N'2011-11-22T00:00:00.000', N'2011-11-23T00:00:00.000', 
N'2011-11-24T00:00:00.000', N'2011-11-25T00:00:00.000', N'2011-11-26T00:00:00.000', N'2011-11-27T00:00:00.000', N'2011-11-28T00:00:00.000', 
N'2011-11-29T00:00:00.000', N'2011-11-30T00:00:00.000', N'2011-12-01T00:00:00.000', N'2011-12-02T00:00:00.000', N'2011-12-03T00:00:00.000', 
N'2011-12-04T00:00:00.000', N'2011-12-05T00:00:00.000', N'2011-12-06T00:00:00.000', N'2011-12-07T00:00:00.000', N'2011-12-08T00:00:00.000', 
N'2011-12-09T00:00:00.000', N'2011-12-10T00:00:00.000', N'2011-12-11T00:00:00.000', N'2011-12-12T00:00:00.000', N'2011-12-13T00:00:00.000', 
N'2011-12-14T00:00:00.000', N'2011-12-15T00:00:00.000', N'2011-12-16T00:00:00.000', N'2011-12-17T00:00:00.000', N'2011-12-18T00:00:00.000', 
N'2011-12-19T00:00:00.000', N'2011-12-20T00:00:00.000', N'2011-12-21T00:00:00.000', N'2011-12-22T00:00:00.000', N'2011-12-23T00:00:00.000', 
N'2011-12-24T00:00:00.000', N'2011-12-25T00:00:00.000', N'2011-12-26T00:00:00.000', N'2011-12-27T00:00:00.000', N'2011-12-28T00:00:00.000', 
N'2011-12-29T00:00:00.000', N'2011-12-30T00:00:00.000', N'2011-12-31T00:00:00.000', N'2012-01-01T00:00:00.000', N'2012-01-02T00:00:00.000', 
N'2012-01-03T00:00:00.000', N'2012-01-04T00:00:00.000', N'2012-01-05T00:00:00.000', N'2012-01-06T00:00:00.000', N'2012-01-07T00:00:00.000', 
N'2012-01-08T00:00:00.000', N'2012-01-09T00:00:00.000', N'2012-01-10T00:00:00.000', N'2012-01-11T00:00:00.000', N'2012-01-12T00:00:00.000', 
N'2012-01-13T00:00:00.000', N'2012-01-14T00:00:00.000', N'2012-01-15T00:00:00.000', N'2012-01-16T00:00:00.000', N'2012-01-17T00:00:00.000', 
N'2012-01-18T00:00:00.000', N'2012-01-19T00:00:00.000', N'2012-01-20T00:00:00.000', N'2012-01-21T00:00:00.000', N'2012-01-22T00:00:00.000', 
N'2012-01-23T00:00:00.000', N'2012-01-24T00:00:00.000', N'2012-01-25T00:00:00.000', N'2012-01-26T00:00:00.000', N'2012-01-27T00:00:00.000', 
N'2012-01-28T00:00:00.000', N'2012-01-29T00:00:00.000', N'2012-01-30T00:00:00.000', N'2012-01-31T00:00:00.000', N'2012-02-01T00:00:00.000', 
N'2012-02-02T00:00:00.000', N'2012-02-03T00:00:00.000', N'2012-02-04T00:00:00.000', N'2012-02-05T00:00:00.000', N'2012-02-06T00:00:00.000', 
N'2012-02-07T00:00:00.000', N'2012-02-08T00:00:00.000', N'2012-02-09T00:00:00.000', N'2012-02-10T00:00:00.000', N'2012-02-11T00:00:00.000', 
N'2012-02-12T00:00:00.000', N'2012-02-13T00:00:00.000', N'2012-02-14T00:00:00.000', N'2012-02-15T00:00:00.000', N'2012-02-16T00:00:00.000', 
N'2012-02-17T00:00:00.000', N'2012-02-18T00:00:00.000', N'2012-02-19T00:00:00.000', N'2012-02-20T00:00:00.000', N'2012-02-21T00:00:00.000', 
N'2012-02-22T00:00:00.000', N'2012-02-23T00:00:00.000', N'2012-02-24T00:00:00.000', N'2012-02-25T00:00:00.000', N'2012-02-26T00:00:00.000', 
N'2012-02-27T00:00:00.000', N'2012-02-28T00:00:00.000', N'2012-02-29T00:00:00.000', N'2012-03-01T00:00:00.000', N'2012-03-02T00:00:00.000', N'2012-03-03T00:00:00.000', 
N'2012-03-04T00:00:00.000', N'2012-03-05T00:00:00.000', N'2012-03-06T00:00:00.000', N'2012-03-07T00:00:00.000', N'2012-03-08T00:00:00.000', 
N'2012-03-09T00:00:00.000', N'2012-03-10T00:00:00.000', N'2012-03-11T00:00:00.000', N'2012-03-12T00:00:00.000', N'2012-03-13T00:00:00.000', 
N'2012-03-14T00:00:00.000', N'2012-03-15T00:00:00.000', N'2012-03-16T00:00:00.000', N'2012-03-17T00:00:00.000', N'2012-03-18T00:00:00.000', 
N'2012-03-19T00:00:00.000', N'2012-03-20T00:00:00.000', N'2012-03-21T00:00:00.000', N'2012-03-22T00:00:00.000', N'2012-03-23T00:00:00.000', 
N'2012-03-24T00:00:00.000', N'2012-03-25T00:00:00.000', N'2012-03-26T00:00:00.000', N'2012-03-27T00:00:00.000', N'2012-03-28T00:00:00.000', 
N'2012-03-29T00:00:00.000', N'2012-03-30T00:00:00.000', N'2012-03-31T00:00:00.000', N'2012-04-01T00:00:00.000', N'2012-04-02T00:00:00.000', 
N'2012-04-03T00:00:00.000', N'2012-04-04T00:00:00.000', N'2012-04-05T00:00:00.000', N'2012-04-06T00:00:00.000', N'2012-04-07T00:00:00.000', 
N'2012-04-08T00:00:00.000', N'2012-04-09T00:00:00.000', N'2012-04-10T00:00:00.000', N'2012-04-11T00:00:00.000', N'2012-04-12T00:00:00.000', 
N'2012-04-13T00:00:00.000', N'2012-04-14T00:00:00.000', N'2012-04-15T00:00:00.000', N'2012-04-16T00:00:00.000', N'2012-04-17T00:00:00.000', 
N'2012-04-18T00:00:00.000', N'2012-04-19T00:00:00.000', N'2012-04-20T00:00:00.000', N'2012-04-21T00:00:00.000', N'2012-04-22T00:00:00.000', 
N'2012-04-23T00:00:00.000', N'2012-04-24T00:00:00.000', N'2012-04-25T00:00:00.000', N'2012-04-26T00:00:00.000', N'2012-04-27T00:00:00.000', 
N'2012-04-28T00:00:00.000', N'2012-04-29T00:00:00.000', N'2012-04-30T00:00:00.000', N'2012-05-01T00:00:00.000', N'2012-05-02T00:00:00.000', 
N'2012-05-03T00:00:00.000', N'2012-05-04T00:00:00.000', N'2012-05-05T00:00:00.000', N'2012-05-06T00:00:00.000', N'2012-05-07T00:00:00.000', 
N'2012-05-08T00:00:00.000', N'2012-05-09T00:00:00.000', N'2012-05-10T00:00:00.000', N'2012-05-11T00:00:00.000', N'2012-05-12T00:00:00.000', 
N'2012-05-13T00:00:00.000', N'2012-05-14T00:00:00.000', N'2012-05-15T00:00:00.000', N'2012-05-16T00:00:00.000', N'2012-05-17T00:00:00.000', 
N'2012-05-18T00:00:00.000', N'2012-05-19T00:00:00.000', N'2012-05-20T00:00:00.000', N'2012-05-21T00:00:00.000', N'2012-05-22T00:00:00.000', 
N'2012-05-23T00:00:00.000', N'2012-05-24T00:00:00.000', N'2012-05-25T00:00:00.000', N'2012-05-26T00:00:00.000', N'2012-05-27T00:00:00.000', 
N'2012-05-28T00:00:00.000', N'2012-05-29T00:00:00.000', N'2012-05-30T00:00:00.000', N'2012-05-31T00:00:00.000', N'2012-06-01T00:00:00.000', 
N'2012-06-02T00:00:00.000', N'2012-06-03T00:00:00.000', N'2012-06-04T00:00:00.000', N'2012-06-05T00:00:00.000', N'2012-06-06T00:00:00.000', 
N'2012-06-07T00:00:00.000', N'2012-06-08T00:00:00.000', N'2012-06-09T00:00:00.000', N'2012-06-10T00:00:00.000', N'2012-06-11T00:00:00.000', 
N'2012-06-12T00:00:00.000', N'2012-06-13T00:00:00.000', N'2012-06-14T00:00:00.000', N'2012-06-15T00:00:00.000', N'2012-06-16T00:00:00.000', 
N'2012-06-17T00:00:00.000', N'2012-06-18T00:00:00.000', N'2012-06-19T00:00:00.000', N'2012-06-20T00:00:00.000', N'2012-06-21T00:00:00.000', 
N'2012-06-22T00:00:00.000', N'2012-06-23T00:00:00.000', N'2012-06-24T00:00:00.000', N'2012-06-25T00:00:00.000', N'2012-06-26T00:00:00.000', 
N'2012-06-27T00:00:00.000', N'2012-06-28T00:00:00.000', N'2012-06-29T00:00:00.000', N'2012-06-30T00:00:00.000')
GO

-- Create Partition Scheme
CREATE PARTITION SCHEME [SMTP_DayDateRange2PS] AS PARTITION [SMTP_DayDateRange2PF] ALL TO ([RSDW])
GO

-- Create tables
CREATE TABLE [dbo].[fact_smtp_outer_relay_11](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_11] ON [dbo].[fact_smtp_outer_relay_11] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_10](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_10] ON [dbo].[fact_smtp_outer_relay_10] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_9](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
 
CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_9] ON [dbo].[fact_smtp_outer_relay_9] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_8](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_8] ON [dbo].[fact_smtp_outer_relay_8] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_7](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_7] ON [dbo].[fact_smtp_outer_relay_7] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_6](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_6] ON [dbo].[fact_smtp_outer_relay_6] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_5](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_5] ON [dbo].[fact_smtp_outer_relay_5] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_4](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_4] ON [dbo].[fact_smtp_outer_relay_4] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_3](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_3] ON [dbo].[fact_smtp_outer_relay_3] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_2](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_2] ON [dbo].[fact_smtp_outer_relay_2] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_1](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_1] ON [dbo].[fact_smtp_outer_relay_1] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_outer_relay_0](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_outer_relay_0] ON [dbo].[fact_smtp_outer_relay_0] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_11](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_11] ON [dbo].[fact_smtp_inner_relay_11] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_10](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_10] ON [dbo].[fact_smtp_inner_relay_10] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_9](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_9] ON [dbo].[fact_smtp_inner_relay_9] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_8](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_8] ON [dbo].[fact_smtp_inner_relay_8] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_7](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_7] ON [dbo].[fact_smtp_inner_relay_7] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_6](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_6] ON [dbo].[fact_smtp_inner_relay_6] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_5](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_5] ON [dbo].[fact_smtp_inner_relay_5] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_4](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_4] ON [dbo].[fact_smtp_inner_relay_4] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_3](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_3] ON [dbo].[fact_smtp_inner_relay_3] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_2](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_2] ON [dbo].[fact_smtp_inner_relay_2] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_1](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_1] ON [dbo].[fact_smtp_inner_relay_1] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

CREATE TABLE [dbo].[fact_smtp_inner_relay_0](
	[log_date_time] [datetime] NULL,
	[msg_type] [varchar](15) NULL,
	[m_id] [bigint] NULL,
	[ic_id] [bigint] NULL,
	[message] [varchar](2048) NULL,
	[src_file] [varchar](255) NULL,
	[server_name] [varchar](100) NULL
) ON [SMTP_DayDateRange2PS]([log_date_time])
GO
CREATE CLUSTERED INDEX [IX_fact_smtp_inner_relay_0] ON [dbo].[fact_smtp_inner_relay_0] 
(
	[log_date_time] DESC
)WITH (DATA_COMPRESSION = PAGE, PAD_INDEX  = ON, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = ON, ALLOW_ROW_LOCKS  = OFF, ALLOW_PAGE_LOCKS  = OFF, FILLFACTOR = 85) ON [SMTP_DayDateRange2PS]([log_date_time])
GO

-- Create View
CREATE VIEW [dbo].[vw_fact_smtp_inner_relay]
WITH SCHEMABINDING
AS
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_0]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_1]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_2]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_3]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_4]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_5]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_6]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_7]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_8]  
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_9]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_10]
WITH (NOLOCK)
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
FROM [RiskSecurityDW].[dbo].[fact_smtp_inner_relay_11]
WITH (NOLOCK)
GO


CREATE VIEW [dbo].[vw_fact_smtp_outer_relay]
WITH SCHEMABINDING
AS
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_0]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_1]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_2]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_3]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_4]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_5]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_6]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_7]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_8]
UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_9]
  UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_10]
  UNION ALL
SELECT [log_date_time]
      ,[msg_type]
      ,[m_id]
      ,[ic_id]
      ,[message]
      ,[src_file]
      ,[server_name]
  FROM [RiskSecurityDW].[dbo].[fact_smtp_outer_relay_11]
GO

